home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / MacHack 90 Contest Entries / What day is it?.ƒ / WDEF project / wdef_pStr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-15  |  1.0 KB  |  57 lines  |  [TEXT/KAHL]

  1. /*pascal format string functions Written by: Eric J. Hayes*/
  2.  
  3. #include "wdef_pStr.h"
  4.  
  5. /*protos*/
  6.         void    pStrCpy(char*,char*);
  7.         void    pStrCat(char*,char*);
  8.         void    pRightJust(char*,int);
  9.  
  10. void pStrCpy(outStr,inStr)
  11.  char *    inStr;
  12.  char *    outStr;
  13.     {
  14.     int    xx;
  15.     int in  = inStr[0]  & 0x00FF;
  16.     int    out = outStr[0] & 0x00FF;
  17.     
  18.     for (xx=0; xx<=in; xx++)
  19.         outStr[xx] = inStr[xx];
  20.     }
  21.  
  22. void pStrCat(outStr,inStr)
  23.  char *    inStr;
  24.  char *    outStr;
  25.     {
  26.     int    xx;
  27.     int in  = inStr[0]  & 0x00FF;
  28.     int    out = outStr[0] & 0x00FF;
  29.  
  30.     if ( (in + out) > 255 )  /*make sure there is enough room*/
  31.         in = 255 - out;
  32.         
  33.     for (xx=1; xx<=in; xx++)
  34.         outStr[out+xx] = inStr[xx];
  35.     
  36.     outStr[0] = out+in;
  37.     }
  38.  
  39. void pRightJust(theStr,places)
  40.  char *    theStr;
  41.  int            places;
  42.     {
  43.     Str255    tempStr;
  44.     int            theOffset;
  45.     int            xx;
  46.     
  47.     if ( theStr[0] < places )
  48.         {
  49.         pStrCpy((char*)tempStr,(char*)theStr);
  50.         theOffset = places - theStr[0];
  51.         theStr[0] = places;
  52.         for(xx=1    ;xx<=places            ;theStr[xx++] = '0');    
  53.         for(xx=1    ;xx<=theStr[0]    ;theStr[xx+theOffset] = tempStr[xx++]);
  54.         }
  55.     }
  56.     
  57.